#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "${0}")/../.."
APP_ROOT=$(pwd)

function main() {
	cd ${APP_ROOT}
	mkdir -p dist/static/node_modules
	dependencies=(vscode-textmate vscode-oniguruma xterm xterm-addon-search xterm-addon-unicode11 xterm-addon-webgl tas-client-umd iconv-lite-umd jschardet)

	for dependency in ${dependencies[@]};
	do
		rsync -a --del vscode-web-github1s/node_modules/${dependency} dist/static/node_modules
	done

	rsync -a node_modules/@github1s/vscode-web/dist/extensions/ dist/static/extensions
	if [ -z "${DEV_VSCODE-}" ];
	then
		rsync -a --del node_modules/@github1s/vscode-web/dist/vscode/ dist/static/vscode
	fi
	echo "copy necessary node_modules done!"
}

main "$@"
